#pragma once
#include <pthread.h>
#include <string>
#include <functional>
#include <sys/types.h>
#include <unistd.h>

namespace ThreadMoudle
{

    class Cond
    {



    public:
        Cond(pthread_mutex_t* mutex_ptr)
        :_cond(PTHREAD_COND_INITIALIZER),_mutex_ptr(mutex_ptr)
        {

        }
        Cond(pthread_mutex_t& mutex)
        :_cond(PTHREAD_COND_INITIALIZER),_mutex_ptr(&mutex)
        {

        }
        void Wait()
        {
            pthread_cond_wait(&_cond,_mutex_ptr);
        }
        void Signal()
        {
            pthread_cond_signal(&_cond);
        }
        void Broadcast()
        {
            pthread_cond_broadcast(&_cond);
        }
        ~Cond()
        {
            pthread_cond_destroy(&_cond);
        }

    private:
        pthread_cond_t _cond;
        pthread_mutex_t* _mutex_ptr;
    };


}